
//see: 	http://webreflection.blogspot.com/2008/05/habemus-array-unlocked-length-in-ie8.html and
//		http://www.devpro.it/code/184.html and
//		http://www.devpro.it/code/183.html
Stack = function(Stack){
    /**
     * Subclassed JavaScript 1.5 Array for every browser.
     * @author      Andrea Giammarchi
     * @site        devpro.it
     * @blog        webreflection.blogspot.com
     * @date        2008/05/24
     * @requires    IE 5.5+ , FF 1+ , Opera 8+ , Safari 2+
     * @license     Mit Style
     */
    if((new Stack(0,1)).length === 0){
        Stack.prototype = {length:0};
        for(var
            arguments = "pop.push.reverse.shift.sort.splice.unshift.join.slice".split("."),
            length = arguments.length;
            length;
        )
            Stack.prototype[arguments[--length]] = Array.prototype[arguments[length]];
    };
    var slice = Array.prototype.slice;
    Stack.prototype.concat = function(){
        for(var constructor = this.slice(0), i = 0, length = arguments.length; i < length; i++)
            constructor.push.apply(constructor, arguments[i] instanceof Stack ? arguments[i].slice(0) : (arguments[i] instanceof Array ? arguments[i] : [arguments[i]]));
        return  constructor;
    };
    Stack.prototype.toString = function(){
        return  slice.call(this, 0).toString();
    };
    Stack.prototype.constructor = Stack;
    return  Stack;
}(function(){
    function Stack(length){
        if(arguments.length === 1 && typeof length === "number")
            this.length = -1 < length && length === length >> .5 ? length : this.push(length);
        else if(arguments.length)
            this.push.apply(this, arguments);
    };
    function Array(){};
    Array.prototype = [];
    Stack.prototype = new Array;
    Stack.prototype.length = 0;
    return  Stack;
}());



(function(Stack){
    /**
     * Subclassed JavaScript 1.7 Array for every browser.
     * @author      Andrea Giammarchi
     * @site        devpro.it
     * @blog        webreflection.blogspot.com
     * @date        2008/05/20
     * @requires    IE 5.5+ , FF 1+ , Opera 8+ , Safari 2+
     * @license     Mit Style
     */
    function type(value){
        return  value instanceof Array || value instanceof Stack;
    };
    var Object = {
        every:function(callback){
            for(var
                i = 0,
                result = true,
                scope = arguments[1] || null,
                value = type(this);
                i < this.length && result;
                i++
            )
                if(value ? this.hasOwnProperty(i) : this[i] !== undefined)
                    result = callback.call(scope, this[i], i, this);
            return  result;
        },
        filter:function(callback){
            for(var
                i = 0,
                result = [],
                scope = arguments[1] || null,
                value = type(this);
                i < this.length;
                i++
            )
                if((value ? this.hasOwnProperty(i) : this[i] !== undefined) && callback.call(scope, this[i], i, this))
                    result[result.length] = this[i];
            return  result;
        },
        forEach:function(callback){
            for(var
                i = 0,
                scope = arguments[1] || null,
                value = type(this);
                i < this.length;
                i++
            )
                if(value ? this.hasOwnProperty(i) : this[i] !== undefined)
                    callback.call(scope, this[i], i, this);
        },
        indexOf:function(value, i){
            for(var
                j = this.length,
                i = i < 0 ? i + j < 0 ? 0 : i + j : i || 0;
                i < j && this[i] !== value;
                i++
            );
            return  j <= i ? -1 : i;
        },
        lastIndexOf:function(){
            var i   = this.reverse().indexOf.apply(this, arguments);
            this.reverse();
            return  i < 0 ? i : this.length - 1 - i;
        },
        map:function(callback){
            for(var
                i = 0,
                result = new Array(this.length),
                scope = arguments[1] || null,
                value = type(this);
                i < this.length;
                i++
            )
                if(value ? this.hasOwnProperty(i) : this[i] !== undefined)
                    result[i] = callback.call(scope, this[i], i, this);
            return  result;
        },
        some:function(callback){
            for(var
                i = 0,
                result = false,
                scope = arguments[1] || null,
                value = type(this);
                i < this.length && !result;
                i++
            )
                if(value ? this.hasOwnProperty(i) : this[i] !== undefined)
                    result = callback.call(scope, this[i], i, this);
            return  result;
        }
    },
    key;
    for(key in Object)
        Stack.prototype[key] = Array.prototype[key] || Object[key];
})(Stack);